#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
装饰器
"""
import functools


def now():
    print('2025-01-14')


# 注意 f = now 和 f = now()的区别
f = now


# print(f.__name__)


def log(func):
    def wrapper(*args, **kw):
        print('call %s():' % func.__name__)
        return func(*args, **kw)

    return wrapper


@log
def now():
    print('2025-01-14')


now()
print(now.__name__)


def log(text):
    def decorator(func):
        def wrapper(*args, **kw):
            print('%s %s():' % (text, func.__name__))
            return func(*args, **kw)

        return wrapper

    return decorator


@log('execute1')
def now():
    print('2024-6-1')


now()


def log(text):
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kw):
            print('%s %s():' % (text, func.__name__))
            return func(*args, **kw)

        return wrapper

    return decorator


@log('execute2')
def now():
    print('2024-6-1')


print(now.__name__)
